﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ProducerBO;

namespace producer
{
    public partial class AdminClips : System.Web.UI.Page
    {
        CLIPDETAIL cd = new CLIPDETAIL();
        CLIPINFO ci = new CLIPINFO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataTable dt = cd.GetRecords(-99, -99, -99, "", "", "", "", -99, false, true, "and");
                DataTable dt1 = ci.GetRecords(-99, "", "", false, true, "and");
                DropDownList1.DataSource = dt1;
                DropDownList1.DataTextField = "CLIP_ID";
                DropDownList1.DataValueField = "CLIP_ID";
                DropDownList1.DataBind();
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
    
        }

        protected void Save_Click(object sender, EventArgs e)
        {
            cd.CLIPD_ID = -99;
            cd.CLIP_ID = -99;
            cd.CLIPD_S_ID = -99;
            if (FileUpload1.HasFile)
                FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Clip/" + FileUpload1.FileName));
            cd.CLIPD_PHOTO = FileUpload1.FileName;
            cd.CLIPD_LENGTH = txtlength.Text;
            cd.CLIPD_SIZE = txtsize.Text;
            cd.CLIPD_FORMAT = txtformat.Text;
            cd.CLIPD_PRICE = Convert.ToInt64(txtprice.Text);
            cd.ISDELETED = false;
            cd.ISACTIVE = true;
            cd.SaveRecord();
            Response.Redirect("~/AdminClips.aspx");


        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                DataTable dt = cd.GetRecords(Convert.ToInt64(e.CommandArgument),Convert.ToInt64(-99),Convert.ToInt64(-99), "", "", "", "", -99, false, true, "and");
                cd.CLIPD_ID = Convert.ToInt64(dt.Rows[0]["clipd_id"].ToString());
                cd.CLIP_ID = Convert.ToInt64(dt.Rows[0]["clip_id"].ToString());
                cd.CLIPD_S_ID = Convert.ToInt64(dt.Rows[0]["clipd_s_id"].ToString());
                cd.CLIPD_PHOTO = dt.Rows[0]["clipd_photo"].ToString();
                cd.CLIPD_LENGTH = dt.Rows[0]["clipd_length"].ToString();
                cd.CLIPD_SIZE = dt.Rows[0]["clipd_size"].ToString();
                cd.CLIPD_FORMAT = dt.Rows[0]["clipd_format"].ToString();
                
                cd.CLIPD_PRICE = Convert.ToInt64(dt.Rows[0]["clipd_price"].ToString());
                cd.ISDELETED=true;
               // cd.isactive=true;
                cd.SaveRecord();
                Response.Redirect("~/AdminClips.aspx");
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

    }
}
